﻿using System;
using System.Collections;
using System.Data;
using System.Data.OracleClient;
using System.Linq;
using System.Xml.Linq;
using WPFExcelReport;
using ReflectionStudio.Controls;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC : BaseFunction
    {
        public string Company = "ITX";
        public DateTime tomorrow = DateTime.Now.AddDays(1);
        public DateTime yesterday = DateTime.Now.AddDays(-1);
        public string ITXMANDANT = "00", ITXUSER = "ITXVVVK ", ITXDATE = "20120723";
        public string today = "";
        public string Right(string str, int num)
        {
            try
            {
                int leng = str.Length;
                str = str.Substring(leng - num, num);
            }
            catch (Exception ex)
            {
            }
            return str;
        }
        public string Left(string str, int num)
        {
            try
            {
                int leng = str.Length;
                str = str + "                                                                                ";
                str = str.Substring(0, num);
            }
            catch (Exception ex)
            {

            }
            return str;
        }
        OracleCommand or1;
        public GB2312Convert8859P1 gb2312;
        public string ApplicationPath
        {
            get { return System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); }
        }
        public INTEXDBC(OracleConnection _OracleDB, IntexReptServBLClient _proxy)
        {
            OracleDB = _OracleDB;
            proxy = _proxy;
            today = yesterday.Year.ToString() + Right("00" + yesterday.Month.ToString(), 2) + Right("00" + yesterday.Day.ToString(), 2);
            gb2312 = new GB2312Convert8859P1();
            
        }
        public INTEXDBC(OracleConnection _OracleDB, IntexReptServBLClient _proxy, string company)
        {
            OracleDB = _OracleDB;
            proxy = _proxy;
            today = yesterday.Year.ToString() + Right("00" + yesterday.Month.ToString(), 2) + Right("00" + yesterday.Day.ToString(), 2);
            gb2312 = new GB2312Convert8859P1();
            Company = company;
        }
        #region======A==============
        public void SaveAPZUORD(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryAPZUORD(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapAPZUORD(ref dwLocal, dwData);

            if (!flgExist)
            {
                InserAPZUORD(dwLocal);
                string apkrs = dwLocal["APZANRKRS"].ToString();
                string apdnr = dwLocal["APZALFDNR"].ToString();
                RefreshAPKOPF(apkrs, apdnr);
            }
            UpdateAPZUORD(dwLocal);
        }
        private void RefreshAPKOPF(string apkrs, string apdnr)
        {

            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryAPKOPF(apkrs, apdnr);
            double APKAENDZL = 0;
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
            }

            if (dwLocal != null)
            {
                APKAENDZL = System.Convert.ToDouble(dwLocal["APKAENDZL"].ToString()) + 1;
                dwLocal["APKAENDZL"] = APKAENDZL;
                UpdateAPKOPF(dwLocal);
            }
        }

        public void SaveABARTE(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryABARTE(dwData, 1);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapABARTE(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertABARTE(dwLocal, ITXDBVERSION);
            }
            UpdateABARTE(dwLocal);
        }
        public void SaveABAUFM(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryABAUFM(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapABAUFM(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertABAUFM(dwLocal, ITXDBVERSION);
            }
            UpdateABAUFM(dwLocal);
        }
        public void SaveABFOLGE(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryABFOLGE(dwData, 3);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapABFOLGE(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertABFOLGE(dwLocal, ITXDBVERSION);
            }
            UpdateABFOLGE(dwLocal);
        }
        public void SaveABKOPF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryABKOPF(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapABKOPF(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertABKOPF(dwLocal, ITXDBVERSION);
            }
            UpdateABKOPF(dwLocal);
        }
        public void SaveABPOS(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryABPOS(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapABPOS(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertABPOS(dwLocal, ITXDBVERSION);
            }
            UpdateABPOS(dwLocal);
        }
        public void SaveICC_ABPOSFS(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryICC_ABPOSFS(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapICC_ABPOSFS(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertICC_ABPOSFS(dwLocal, ITXDBVERSION);
            }
            UpdateICC_ABPOSFS(dwLocal, 1);
        }
        public void SaveABPR(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryABPR(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapABPR(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertABPR(dwLocal, ITXDBVERSION);
            }
            UpdateABPR(dwLocal);
        }
        public void SaveICC_ABPOS_MCO(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryICC_ABPOS_MCO(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapICC_ABPOS_MCO(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertICC_ABPOS_MCO(dwLocal, 1,ITXDBVERSION);
            }
            UpdateICC_ABPOS_MCO(dwLocal);
        }
        
        #endregion

        #region======B==============
        public void SaveBASTGA(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryBASTGA(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapBASTGA(ref dwLocal, dwData);
            InsertBASTGA(dwLocal);
            UpdateBASTGA(dwLocal);
        }
        public void SaveBASTGAD(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryBASTGAD(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapBASTGAD(ref dwLocal, dwData);
            InsertBASTGAD(dwLocal);
            UpdateBASTGAD(dwLocal);
        }
        public void SaveBHSATZ(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryBHSATZ(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapBHSATZ(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertBHSATZ(dwLocal);
            }
            UpdateBHSATZ(dwLocal);
        }
        public void SaveBSGROE(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryBSGROE(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapBSGROE(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertBSGROE(dwLocal);
            }
            UpdateBSGROE(dwLocal);
        }
        public void SaveBSFARB(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryBSFARB(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapBSFARB(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertBSFARB(dwLocal);
            }
            UpdateBSFARB(dwLocal);
        }
        public void SaveBSSATZ(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryBSSATZ(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapBSSATZ(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertBSSATZ(dwLocal);
            }
            UpdateBSSATZ(dwLocal);
        }

        public void SaveBABST(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryBABST(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapBABST(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertBABST(dwLocal);
            }
            UpdateBABST(dwLocal);
        }
        public void SaveBAAUF(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryBAAUF(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapBAAUF(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertBAAUF(dwLocal);
            }
            UpdateBAAUF(dwLocal);
        }

        #endregion

        #region======C==============
        #endregion

        #region======D==============
        #endregion

        #region======E==============
        public void SaveEKKOPF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryEKKOPF(dwData, 1);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapEKKOPF(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertEKKOPF(dwLocal);
            }
            UpdateEKKOPF(dwLocal);
        }
        public void SaveEKVRECH(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryEKVRECH(dwData, 1);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapEKVRECH(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertEKVRECH(dwLocal);
            }
            UpdateEKVRECH(dwLocal);
        }
        public void SaveEKPOS(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryEKPOS(dwData, 1);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            //MapEKPOS(ref dwLocal, dwData);
            //Because contains the RAW data in the databaes, so the dwData will not map to the dwLoacl
            //sunlight 20130815
            if (!flgExist)
            {
                InsertEKPOS(dwData);
            }
            UpdateEKPOS(dwData);
        }
        #endregion

        #region======F==============
        public void SaveFDECK(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryFDECK(dwData, 2);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapFDECK(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertFDECK(dwLocal);
            }
            UpdateFDECK(dwLocal);
        }
        public void SaveFSSTUELI(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryFSSTUELI(dwData, 1);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapFSSTUELI(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertFSSTUELI(dwLocal);
            }
            UpdateFSSTUELI(dwLocal);
        }
        public void SaveFBST(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryFBST(dwData, 3);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapFBST(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertFBST(dwLocal);
            }
            UpdateFBST(dwLocal);
        }
        public void SaveFGBST(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryFGBST(dwData, 1);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapFGBST(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertFGBST(dwLocal);
            }
            UpdateFGBST(dwLocal);
        }
        public void SaveFBEW(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryFBEW(dwData, 1);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapFBEW(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertFBEW(dwLocal);
            }
            UpdateFBEW(dwLocal);
        }
        public void SaveFCHAR(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryFCHAR(dwData, 2);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapFCHAR(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertFCHAR(dwLocal);
            }
            UpdateFCHAR(dwLocal);
        }
        
        #endregion

        #region======G==============

        public void SaveGAAUF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryGAAUF(dwData, 1);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapGAAUF(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertGAAUF(dwLocal);
            }
            UpdateGAAUF(dwLocal);
        }
        public void SaveGSCOLOR(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryGSCOLOR(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapGSCOLOR(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertGSCOLOR(dwLocal);
            }
            UpdateGSCOLOR(dwLocal);
        }
        public void SaveGASTGA(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryGASTGA(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapGASTGA(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertGASTGA(dwLocal);
            }
            UpdateGASTGA(dwLocal);
        }
        public void SaveGZKON(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryGZKON(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapGZKON(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertGZKON(dwLocal);
            }
            UpdateGZKON(dwLocal);
        }


        #endregion

        #region======H==============
        #endregion

        #region======K==============
        //KDSTAMM KUNDVER
        public void SaveKDSTAMM(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            Result = QueryKDSTAMM(dwData);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapKDSTAMM(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertKDSTAMM(dwLocal);
            }
            UpdateKDSTAMM(dwLocal);

        }
        public void SaveKSLEIST(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            Result = QueryKSLEIST(dwData);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapKSLEIST(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertKSLEIST(dwLocal);
            }
            UpdateKSLEIST(dwLocal);

        }
        
        public void SaveKUNDVER(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            Result = QueryKUNDVER(dwData);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapKUNDVER(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertKUNDVER(dwLocal);
            }
            UpdateKUNDVER(dwLocal);

        }
        #endregion

        #region======L==============

        public void SaveLOGINFO(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            Result = QueryLOGINFO(dwData);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            if (dwLocal == null)
                dwLocal = dwData;
            MapLOGINFO(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertLOGINFO(dwLocal);
            }
            UpdateLOGINFO(dwLocal);

        }
        #endregion

        #region======M==============
        public void SaveMDECK(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryMDECK(dwData, 2);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapMDECK(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertMDECK(dwLocal);
            }
            UpdateMDECK(dwLocal);
        }
        #endregion

        #region======P==============
        #endregion

        #region======Q==============

        public void SaveQPZUORD(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryQPZUORD(dwData, 3);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapQPZUORD(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertQPZUORD(dwLocal);
            }
            UpdateQPZUORD(dwLocal);
        }
        #endregion

        #region=====S==============
        public void SaveSDDAT(DataRow dwData)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;

            setResult = QuerySDDAT(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapWAFARBEN(ref dwLocal, dwData);
            if (!flgExist)
            {
                InsertSDDAT(dwLocal);
            }
            UpdateSDDAT(dwLocal);
        }
        #endregion

        #region======W==============
        
        public void SaveWAFARBEN(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWAFARBEN(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapWAFARBEN(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWAFARBEN(dwLocal);
            }
            UpdateWAFARBEN(dwLocal);
        }
        public void SaveWAPROF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWAPROF(dwData,2);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapWAPROF(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWAPROF(dwLocal);
            }
            UpdateWAPROF(dwLocal);
        }
        public void SaveWASTAMM(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            bool IsUseCurrentWS05 = true;
            setResult = QueryWASTAMM(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapWASTAMM(ref dwLocal, dwData, flgExist, IsUseCurrentWS05);

            if (!flgExist)
            {
                InsertWASTAMM(dwLocal);
            }
            UpdateWASTAMM(dwLocal);
        }
        public void SaveWASTKE(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWASTKE(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapWASTKE(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWASTKE(dwLocal);
            }
            UpdateWASTKE(dwLocal);
        }
        public void SaveWASTGA(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWASTGA(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapWASTGA(ref dwLocal, dwData);

            InsertWASTGA(dwLocal);
            UpdateWASTGA(dwLocal);
        }
        public void SaveWASTPASS(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWASTPASS(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapWASTPASS(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWASTPASS(dwLocal);
            }
            UpdateWASTPASS(dwLocal);
        }
        public void SaveWBBEW(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWBBEW(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapWBBEW(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWBBEW(dwLocal, ITXDBVERSION);
            }
            UpdateWBBEW(dwLocal);
        }
        public void SaveWBBST(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWBBST(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapWBBST(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWBBST(dwLocal, ITXDBVERSION);
            }
            UpdateWBBST(dwLocal);
        }
        public void SaveWBDAT(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWBDAT(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapWBDAT(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWBDAT(dwLocal);
            }
            UpdateWBDAT(dwLocal);
        }
        public void SaveWDECK(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWDECK(dwData, 5);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapWDECK(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWDECK(dwLocal);
            }
            UpdateWDECK(dwLocal);
        }
        public void SaveWGBST(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWGBST(dwData, 2);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapWGBST(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWGBST(dwLocal);
            }
            UpdateWGBST(dwLocal);
        }
        public void SaveWTEINZ(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWTEINZ(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapWTEINZ(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWTEINZ(dwLocal);
            }
            UpdateWTEINZ(dwLocal);
        }
        public void SaveWTGEW(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWTGEW(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapWTGEW(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWTGEW(dwLocal);
            }
            UpdateWTGEW(dwLocal);
        }
        public void SaveWTPASS(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWTPASS(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapWTPASS(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWTPASS(dwLocal);
            }
            UpdateWTPASS(dwLocal);
        }
        public void SaveWTSCHUSS(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWTSCHUSS(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapWTSCHUSS(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWTSCHUSS(dwLocal);
            }
            UpdateWTSCHUSS(dwLocal);
        }
        public void SaveWTSAER(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWTSAER(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapWTSAER(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWTSAER(dwLocal);
            }
            UpdateWTSAER(dwLocal);
        }
        #endregion

        #region======V==============
        public void SaveVKKOPF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            Result = QueryVKKOPF(dwData);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapVKKOPF(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertVKKOPF(dwLocal, ITXDBVERSION);
            }
            UpdateVKKOPF(dwLocal);

        }
        public void SaveVKPOS(DataRow dwData, string ITXDBVERSION = "50.24",int option=1)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryVKPOS(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapVKPOS(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertVKPOS(dwLocal, ITXDBVERSION);
            }
            UpdateVKPOS(dwLocal,"",option);

        }

        public void SaveVAFARBEN(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryVAFARBEN(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapVAFARBEN(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertVAFARBEN(dwLocal, ITXDBVERSION);
            }
            UpdateVAFARBEN(dwLocal);
        }
        public void SaveVVLIEF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryVVLIEF(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapVVLIEF(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertVVLIEF(dwLocal, ITXDBVERSION);
            }
            UpdateVVLIEF(dwLocal);
        }
        public void SaveVVTLIEF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryVVTLIEF(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapVVTLIEF(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertVVTLIEF(dwLocal, ITXDBVERSION);
            }
            UpdateVVTLIEF(dwLocal);
        }
        public void SaveVVPACK(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryVVPACK(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapVVPACK(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertVVPACK(dwLocal, ITXDBVERSION);
            }
            UpdateVVPACK(dwLocal);
        }
        #endregion
        #region======X==============
        public void SaveICC_XDECK(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            Result = QueryICC_XDECK(dwData);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapICC_XDECK(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertICC_XDECK(dwLocal, ITXDBVERSION);
            }
            UpdateICC_XDECK(dwLocal);

        }
        #endregion
        #region===ICC============
        public void SaveICC_FOLDERS(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
  
            Result = QueryICC_FOLDERS(dwData);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            dwLocal.ItemArray = dwData.ItemArray;
           
            if (!flgExist)
            {
                InsertICC_FOLDERS(dwData, ITXDBVERSION);
            }
            UpdateICC_FOLDERS(dwLocal);

        }
        public void SaveICC_FUNCTIONS(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            Result = QueryICC_FUNCTIONS(dwData);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapICC_FUNCTIONS(ref dwLocal, dwData);
           
            if (!flgExist)
            {
                InsertICC_FUNCTIONS(dwData, ITXDBVERSION);
            }
            UpdateICC_FUNCTIONS(dwLocal);
        }
        public void SaveICC_MENUDEF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            Result = QueryICC_MENUDEF(dwData);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapICC_MENUDEF(ref dwLocal, dwData);
           
            if (!flgExist)
            {
                InsertICC_MENUDEF(dwData, ITXDBVERSION);
            }
           UpdateICC_MENUDEF(dwLocal);

        }
        #endregion
    }
}